package com.longrise.android.byjk.common;

import android.annotation.SuppressLint;
import java.util.HashMap;
import java.util.Map;

@SuppressLint("UseSparseArrays")
public class ListItemState {
	
	/**
	 * 存储记录
	 * 
	 * 结构：          数值：对象
	 * return  对象.get(数值)
	 * 
	 * 适用于ExpandAbleListView
	 * */
	
	private Map<Integer, Map<Integer, Boolean>> mStateMap = new HashMap<Integer, Map<Integer, Boolean>>();
	
	private static ListItemState mListItemState;
	
	public static ListItemState getState(String layer){
		if(mListItemState == null){
			synchronized (ListItemState.class) {
				if(mListItemState == null){
					mListItemState = new ListItemState();
				}
			}
		}
		return mListItemState;
	}
	
	@SuppressLint("UseSparseArrays") 
	public void setExpand(int out, int in, boolean bool){
		Map<Integer, Boolean> map = new HashMap<Integer, Boolean>();
		map.put(in, bool);
		mStateMap.put(out, map);
	}
	
	public boolean getExpand(int out, int in){
		boolean bool = false;
		if(mStateMap.containsKey(out)){
			Map<Integer, Boolean> item = mStateMap.get(out);
			if(item.containsKey(in)){
				bool = item.get(in);
			}
		}
		return bool;
	}

}
